package yiliubabalongcaisuyun.com.longcai.longcaisuyun.testgrid;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.GridView;

import java.util.ArrayList;
import java.util.List;

public class TestActivity extends AppCompatActivity {

    private RecyclerView mRecyclerView;
    private List<String> mDatas;
    private MyAdapter myAdapter;
    private GridLayoutManager gridLayoutManager;
    GridAdapter gridAdapter;

    GridView grid_layout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        gridLayoutManager = new GridLayoutManager(this, 2);
        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                return 1;
            }
        });
        initData();
        grid_layout = (GridView) findViewById(R.id.grid_layout);
        gridAdapter = new GridAdapter(TestActivity.this, mDatas);
        grid_layout.setAdapter(gridAdapter);
    }

    protected void initData() {
        mDatas = new ArrayList<String>();
        for (int i = 1; i <= 7; i++) {
            mDatas.add("" + i);
        }
    }
}
